<?php use_helper('Javascript') ?>
<script src="/public_html/js/jquery-1.5.1.min.js" type="text/javascript"></script>
<?php /* @var $calendar Calendar */ ?>
<div id="calendar"></div>
<div id="loader" style="
display:none;
" ><?php echo image_tag('loader.gif')?>
</div>
<?php echo checkbox_tag('calendarrepeat'
						, 1
						, 0
						, array('onclick' => 'onRepeatEventClicked(' . $calendar->getId() . ')'));?>
<?php if( ($calendar->getDuration() > 0) && ($calendar->getDurationMetric()!=='') && ($calendar->getTimesToRepeat()>0) ): ?>
    <?php echo format_number_choice(
    '[1]One time repeated event.|(1,+Inf]%count% times repeated event',
    array('%count%' => $calendar->getTimesToRepeat()),
    $calendar->getTimesToRepeat()
  )
?>
<?php endif; ?>
<script type="text/javascript">
    function onRepeatEventClicked(id)
    {
        if(jQuery('#calendarrepeat').attr('checked'))
        {
            jQuery.ajax({
                type: "post"
                , data: ({'id': id })
                , dataType: "html"
                , url: "/public_html/test.php/calendar/repeat"
                , success: function(data) {
                    jQuery('#calendar').html(data);
                    jQuery("#loader").hide();
                  }
                , error: function() { console.debug("error"); }
                , beforeSend : function() { jQuery("#loader").show(); }
            });
        }else
        {
            jQuery('#update_calendar').hide();
        }
    }
</script>